import 'package:flutter/material.dart';
import 'package:common/common.dart';

class FondNewVersionDialog extends StatefulWidget {
  final String version;

  const FondNewVersionDialog({Key key, this.version}) : super(key: key);

  @override
  _FondNewVersionDialogState createState() => _FondNewVersionDialogState();

  static show(BuildContext context, String version) {
    showDialog(
        barrierDismissible: false,
        context: context,
        child: Dialog(
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(8),
            ),
            child: FondNewVersionDialog(
              version: version,
            )));
  }
}

class _FondNewVersionDialogState extends State<FondNewVersionDialog> {
  TextStyle contentStyle = TextStyle(color: Color(0xFF6F7275), fontSize: 15);
  TextStyle buttonStyle = TextStyle(fontSize: 14, color: TColor.primeColor);

  @override
  Widget build(BuildContext context) {
    return Container(
        height: 180,
        width: (AppFlavor.flavor == Flavor.Machine||AppFlavor.flavor == Flavor.Maker)? 200: null,
        child: Column(
          children: [
            SizedBox(
              height: 15,
            ),
            Center(
              child: Text(
                '提示信息',
                style: TextStyle(color: TColor.textBlack, fontSize: 15, fontWeight: FontWeight.w500),
              ),
            ),
            Expanded(
              child: Center(child: Text('当前已是最新版本\n版本号：${widget.version}', style: contentStyle)),
            ),
            Divider(height: 0.5),
            Container(
              height: 40,
              child: GestureDetector(
                  behavior: HitTestBehavior.opaque,
                  onTap: () {
                    Navigator.of(context).maybePop();
                  },
                  child: Center(child: Text('确定', style: buttonStyle))),
            ),
          ],
        ));
  }
}
